
import BaseElement from './base';
/**
 * 绘制长方形
 * @param {*} x
 * @param {*} y
 * @param {*} width
 * @param {*} height
 * @param {*} color
 */
let index = 1;
class RectElement extends BaseElement {
	constructor(props) {
		props.type = "RectElement";
		super(props);
		this.id = `RectElement_${index++}`;
	}
	drawSpecial() {
		this.canvas.ctx.moveTo(this.x, this.y);
		this.canvas.ctx.beginPath();
		this.canvas.ctx.rect(this.x, this.y, this.width, this.height);
		this.canvas.ctx.font = "16px Verdana";
		if (this.text) {
			this.canvas.ctx.fillText(this.text, this.x + 20, this.y + this.height / 2);
		}
		this.canvas.ctx.stroke();
		this.canvas.ctx.closePath();
	}
	hover() {
		const args = Array.prototype.slice.call(arguments)
		super.hover.apply(this, args);
	}
	drug() {
		super.drug();
	}
}

export default RectElement;